<?php
	session_start();
	header("Content-Type: text/html;charset=utf-8");
	$conn = mysqli_connect('8.129.105.38','db_lsp','123456');
	if($conn){
		$select = mysqli_select_db($conn,"db_lsp");		
		if($select){

			if(isset($_POST["sub_teacher"])){
				
				$user = $_POST["username"];
				$password = $_POST["password"];
				if($user == ""||$password == ""){
					echo"<script type="."\""."text/javascript"."\"".">"."window.alert"."("."\""."用户名或密码不能为空！"."\"".")".";"."</script>";
					echo"<script type="."\""."text/javascript"."\"".">"."window.location="."\""."登录_teacher.html"."\""."</script>";
					exit;
				}
				$sql_select = "select teacher_id,teacher_pwd from t_db_user where teacher_id = '$user' and teacher_pwd = '$password'";
				mysqli_query($conn,'SET NAMES UTF8');
				$ret = mysqli_query($conn,$sql_select);
				$row = mysqli_fetch_array($ret); 
				$_SESSION[classification]="teacher";
				if($user == $row['teacher_id']&&$password == $row['teacher_pwd']){
					 header("Location:主页.html");
				}else{
					echo"<script type="."\""."text/javascript"."\"".">"."window.alert"."("."\""."账号或密码错误！"."\"".")".";"."</script>";
					echo"<script type="."\""."text/javascript"."\"".">"."window.location="."\""."登录_teacher.html"."\""."</script>";
					exit;
				}  
			}
		}
		mysqli_close($conn);
	}else{		
		die('Could not connect:'.mysql_error());
	}	
 ?>
